package com.blogs.web.controller;

/**
 * @Author: xiaokai
 * @Description:
 * @Date: 2019/8/8
 * @Version: 1.0
 */
public class ThreadDemo extends Thread {
    /*线程第一种实现方式继承Thread类创建接口*/
    public void run() {
        System.out.println("ThreadDemo.run()");
    }

    public static void main(String[] args) {
        ThreadDemo threadDemo = new ThreadDemo();
        threadDemo.start();
    }

}


/*第二种实现方式通过Runnable接口创建类线程*/
class MyThread implements Runnable {

    @Override
    public void run() {
        System.out.println("MyThread.run()");

    }
    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        Thread thread = new Thread(myThread);

        thread.start();
    }
}




